export default {
    namespaced:true,
    state:{
        address:uni.getStorageSync('address'),
        token:uni.getStorageSync('token'),
        userInfo: uni.getStorageSync('userInfo'),
        navUrl:null // 跳转的url方便登录成功后再跳回去
    },
    getters:{
        getAddress(state){
            return state.address
        },
        addressStr(state){
            if(state.address){
                return `${state.address.provinceName}${state.address.cityName}${state.address.countyName}${state.address.detailInfo}`
            }else{
                return ''
            }
        },
        getToken(state){
            return state.token
        },
        getUserInfo (state) {
            return state.userInfo
          },
        getNavUrl(state){
            return state.navUrl
        }
    },
    mutations:{
        setAddress(state,address){
            state.address=address
            // 保存到本地
            uni.setStorageSync('address', address)
        },
        setToken (state, token) {
            state.token = token
      
            uni.setStorageSync('token', state.token)
          },
          setUserInfo (state, userInfo) {
            state.userInfo = userInfo
      
            uni.setStorageSync('userInfo', state.userInfo)
          },
        setNavUrl(state,navUrl){
            state.navUrl = navUrl
        }
    }
}